﻿<%@ Page Title="添加角色" Language="C#" MasterPageFile="~/Layouts/Form.Master" AutoEventWireup="true"
    CodeBehind="OrgAndRoleAdd.aspx.cs" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.User.OrgAndRoleAdd" %>

<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>
<%@ Import Namespace="Bingosoft.Web.Utils" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <web:Script ID="Script2" src="~/Widgets/core/inputpro/ui.inputpro.js" runat="server" />
    <web:Script ID="Script1" src="~/Modules/SecurityConsole/Common/FunctionControl/CategorySelect/CategorySelectControl.js"
        runat="server" />
    <%-- <web:Script ID="Script3" src="~/Widgets/Validator/jquery.validation.js"
        runat="server" />--%>
    <web:Script ID="Script5" src="~/Widgets/core/inputpro/ui.inputpro.js" runat="server" />
    <web:Script ID="Script4" src="~/Modules/SecurityConsole/Common/FunctionControl/ListSelect/ListSelectControl.js"
        runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <script type="text/javascript">
        var Global = {};
        Global.contextPath = '<%= RequestHelper.GetContextPath(Request) %>';
    </script>
    <!-- 页面头部 -->
    <div class="header">
        <h1>
            添加流程角色</h1>
    </div>
    <asp:HiddenField ID='Id' runat='server' Value='<%# Bind("Id") %>' />
    <div>
        <table cellpadding='2' cellspacing='1' width='100%' class="formitem">
            <caption>
                <%=Request["title"]%></caption>
            <tr>
                <th width="30%">
                    组织名称：<font color='red'>*</font>
                </th>
                <td>
                    <asp:HiddenField runat="server" ID="hfOrgId" />
                    <asp:TextBox runat="server" ID="txtOrgName" ReadOnly="true" Width="450px"> </asp:TextBox>
                    <img id="Img3" runat="server" alt="选择组织" src="~/Images/ico_preview.gif" onclick="chooseOrg()"
                        style="cursor: pointer" />
                </td>
            </tr>
            <tr>
                <th width="30%">
                    角色名称：<font color='red'>*</font>
                </th>
                <td>
                    <asp:HiddenField runat="server" ID="hfRoleIds" />
                    <asp:TextBox ID='txtRoleNames' runat='server' Width='450px' ReadOnly="true" validator="required"></asp:TextBox>
                    <img id="Img1" runat="server" alt="选择角色" src="~/Images/ico_preview.gif" onclick="chooseRole()"
                        style="cursor: pointer" />
                </td>
            </tr>
        </table>
    </div>
    <!-- 页脚区域 -->
    <div class="footer">
        <asp:Button ID="btnOK" runat="server" Text="确定" OnClientClick="return validateForm();"
            OnClick="btnOK_Click" />
        <input type="button" name="input1" value="关闭" onclick="window.close();" />
    </div>
    <script type="text/javascript">

        var userId = '<%=Request.Params["UserId"] %>';
       
        function chooseOrg() {
            process({
                sqlId: 'organization.firstFloor.tree',
                childSqlId: 'organization.getChildren',
                title: '组织机构选择',
                idField: "ctl00_Content_hfOrgId",
                nameField: "ctl00_Content_txtOrgName",
                isAsyn: 'true',
                params: {}
            });
        }
        function chooseRole() {
            var listSelect = new ListSelect();
            listSelect.setSearch("角色名称");
            listSelect.setSelectList("sql", "user.role.searchProcessRoleByName");
            listSelect.setParams("{'UserId':'" + userId + "'}");
            listSelect.setTitle('选择角色');
            var result = listSelect.show(Global.contextPath);
            var ids = "";
            var texts = "";
            if (result != null && result[0].length > 0) {
                var len = result[0].length;
                for (var i = 0; i < len; i++) {
                    ids += result[0][i] + ",";
                    texts += result[1][i] + ",";
                }
                if (i > 0) {
                    ids = ids.substring(0, ids.length - 1);
                    texts = texts.substring(0, texts.length - 1);
                }
                document.getElementById("ctl00_Content_hfRoleIds").value = ids;
                document.getElementById("ctl00_Content_txtRoleNames").value = texts;
            }
        } 
    </script>
</asp:Content>
